﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using Draco.Commons.Security.Encrypt;

namespace Draco.Commons.Security
{
    /// <summary>
    /// 字符加密类
    /// </summary>
    public class EncryptUtils
    {
        /// <summary>
        /// DES加密字符串
        /// </summary>
        /// <param name="Text">待加密字符串</param>
        /// <param name="Key">密钥串</param>
        /// <returns></returns>
        public static string DES_Encrypt(string Text, string Key)
        {
            DESCryptoServiceProvider Provider = DESEncrypt.CreateKey(Key);
            return DESEncrypt.Encrypt(Text, Provider);
        }
        /// <summary>
        /// 解密字符串
        /// </summary>
        /// <param name="strCypherText">密文</param>
        /// <param name="key">密钥串</param>
        /// <returns></returns>
        public static string DES_Decrypt(string strCypherText, string key)
        {
            DESCryptoServiceProvider Provider = DESEncrypt.CreateKey(key);
            return DESEncrypt.Decrypt(strCypherText, Provider);
        }

        /// <summary>
        ///  哈希加密(GB2312编码+sha1算法)
        /// </summary>
        /// <param name="Text">待加密字符串</param>
        /// <returns></returns>
        public static string SHA_EncryptHash(string Text)
        {
            return HashEncrypt.EncryptSha1(Text);
        }

    }
}
